local skels = {}

for i = 1, 30 do
  local skill = fk.CreateSkill{
    name = "pegasus__wendao" .. i,
    tags = { Skill.Limited },
  }

  Fk:loadTranslationTable{
    [skill.name] = "问道",
    [":" .. skill.name] = "限定技，出牌阶段限一次，你可以令一名角色进行【浮雷】判定直至因此受到伤害，然后你令一名角色获得这些判定牌，若不为同一名角色，失去此技能。"
    .. "<br/><font color='grey'><small>衍生自第" .. i .. "次〖弘法〗</small></font>",
  }

  skill:addEffect("active", {
    anim_type = "offensive",
    prompt = "#pegasus__wendao",
    can_use = function (self, player)
      return player:usedSkillTimes(skill.name, Player.HistoryGame) == 0
    end,
    target_num = 1,
    card_num = 0,
    target_filter = function (self, player, to_select, selected)
      return #selected < 1
    end,
    card_filter = Util.FalseFunc,
    on_use = function (self, room, effect)
      local player = effect.from
      local target = effect.tos[1]
      local cards = {}

      while true do
        local judge = {
          who = target,
          reason = "floating_thunder",
          pattern = ".|.|spade",
        }
        room:judge(judge)
        if judge.card then
          table.insertIfNeed(cards, judge.card)
          if judge.card.suit == Card.Spade and not target.dead then
            room:damage{
              to = target,
              damage = 1,
              damageType = fk.ThunderDamage,
              skillName = skill.name,
            }
            break
          end
        end
      end

      cards = table.filter(cards, function (id)
        return room:getCardArea(id) == Card.DiscardPile
      end)
      if #cards == 0 then return end

      local targetB = room:askToChoosePlayers(player, {
        targets = room.alive_players,
        min_num = 1,
        max_num = 1,
        skill_name = skill.name,
        cancelable = false,
        prompt = "#pegasus__wendao-give"
      })[1]

      if targetB ~= target then
        room:handleAddLoseSkills(player, "-" .. skill.name)
      end

      room:moveCardTo(cards, Card.PlayerHand, targetB, fk.ReasonJustMove, skill.name, nil, true, player)
    end
  })

  table.insert(skels, skill)
end

return skels